package com.yy.mydota;

import com.yy.widget.SwitchButton;
import com.yy.widget.SwitchButton.OnChangeListener;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.Toast;

public class SettingActivity extends Activity{
	private ImageView iv_back,itemWifiWarning_img;
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.setting_activity);
		getWindow().setBackgroundDrawableResource(R.color.listitem_transparent);
		initUI();
	}

	private void initUI() {
		iv_back = (ImageView) findViewById(R.id.iv_back);
		iv_back.setOnClickListener(settingOnClick);
		itemWifiWarning_img = (ImageView) findViewById(R.id.itemWifiWarning_img);
		itemWifiWarning_img.setOnClickListener(settingOnClick);
		
//		SwitchButton sb = (SwitchButton) findViewById(R.id.switch_btn_wifi);
//		sb.setOnChangeListener(new OnChangeListener() {
//			
//			@Override
//			public void onChange(SwitchButton sb, boolean state) {
//				Log.d("switchButton", state ? "开":"关");  
//                Toast.makeText(SettingActivity.this, state ? "开":"关", Toast.LENGTH_SHORT).show();
//			}
//		});
	}
	
	
	OnClickListener settingOnClick = new OnClickListener() {
		boolean flag;
		@Override
		public void onClick(View v) {
			switch(v.getId()){
			case R.id.iv_back:
				finish();
				overridePendingTransition(android.R.anim.slide_in_left,
						android.R.anim.slide_out_right);
				break;
			case R.id.itemWifiWarning_img:
				if(flag){
					itemWifiWarning_img.setImageResource(R.drawable.switchu);
					flag = false;
				}else{
					itemWifiWarning_img.setImageResource(R.drawable.switchs);
					flag = true;
				}
				break;
			}
			
		}
	};
}
